﻿using System;
using System.Linq;
using TodoMVC.Models.DBModels;

namespace TodoMVC.DBServices
{
    public class DbInitializer
    {
        public static void CreateSqliteFile()
        {

        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        public static void Initialize(TodoMVCContext context)
        {
            InitializeTodoItems(context);
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="context"></param>
        private static void InitializeTodoItems(TodoMVCContext context)
        {
            if (context.TodoItems.Any())
            {
                return;
            }
            context.TodoItems.Add(new TodoItem()
            {
                Content = "吃饭",
                Id = 1,
                Guid = new Guid("00000000000000000000000000000001"),
                CreateTime=new DateTime(2022,1,1,12,0,0)
            });
            context.TodoItems.Add(new TodoItem()
            {
                Content = "睡觉",
                Id = 2,
                Guid = new Guid("00000000000000000000000000000002"),
                CreateTime = new DateTime(2022, 2, 1, 12, 0, 0)
            });
            context.TodoItems.Add(new TodoItem()
            {
                Content = "打豆豆",
                Id = 3,
                Guid = new Guid("00000000000000000000000000000003"),
                CreateTime = new DateTime(2022, 3, 1, 12, 0, 0)
            });
            context.SaveChanges();
        }
    }
}
